import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // 主方法
  @override
  Widget build(BuildContext context) {
    return StateTest();
  }
}

/**
 * 有状态Widget
 */
class StateTest extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _StatetTextState();
  }
}

/**
 * State类
 */
class _StatetTextState extends State<StateTest> {
  bool _light = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: GestureDetector(
        onTap: () {
          print('点击了'+_light.toString());
          setState(() {
            _light = true;
          });
        },
        child: Text(
          'Hello World!',
          textDirection: TextDirection.ltr,
        ),
      ),
    );
  }
}
